package cn.damai.search.baseService.ipml;

import cn.damai.search.baseService.BaseItemService;
import cn.damai.search.mapper.ItemMapper;
import cn.damai.model.Item;
import cn.damai.util.DubboUtil;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;
import java.util.Map;


@Component
@Service(version = DubboUtil.VRESION,group = DubboUtil.GROUP)
public class BaseItemServiceIpml implements BaseItemService {

    @Autowired
    private ItemMapper itemMapper;

    @Override
    public Item getItemById(@RequestParam("id") Long id){
        return itemMapper.getItemById(id);
    }

    @Override
    public List<Item>	getItemListByMap(@RequestBody Map<String,Object> param){
        List<Item> list = itemMapper.getItemListByMap(param);
        return list;
    }

    @Override
    public Integer getItemCountByMap(@RequestBody Map<String,Object> param){
        return itemMapper.getItemCountByMap(param);
    }

    @Override
    public Integer qdtxAddItem(@RequestBody Item Item){
        Item.setCreatedTime(new Date());
        return itemMapper.insertItem(Item);
    }

    @Override
    public Integer qdtxModifyItem(@RequestBody Item Item) {
        Item.setUpdatedTime(new Date());
        return itemMapper.updateItem(Item);
    }
}
